﻿using Microsoft.AspNetCore.Http;
using XCore.Extensions;
using XCore.Dependency;

namespace Web.Admin
{
    /// <summary>
    /// 当前登录管理员信息
    /// </summary>
    public class AdminSession : IScopedDependency
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        public AdminSession(IHttpContextAccessor httpContextAccessor)
        {
            _httpContextAccessor = httpContextAccessor;
        }
        /// <summary>
        /// 当前登录用户名
        /// </summary>
        public string UserName => _httpContextAccessor.HttpContext.GetClaimValue("UserName");
        /// <summary>
        /// 当前登录管理ID
        /// </summary>
        public int AdminId => _httpContextAccessor.HttpContext.GetUserId("AdminId");
        /// <summary>
        /// 租户ID
        /// </summary>
        public int SiteId => _httpContextAccessor.HttpContext.GetClaimValue("SiteId").ToInt();

    }
}
